#!/usr/bin/env python3

"""
biuld-in type and for-looping
"""

import random

# Define the questions and answers
questions = [
    {"question": "What is the output of the following code? print(2 + 3 * 4)", "answer": "14"},
    {"question": "What is the data type of the following expression? 2 + 3.5", "answer": "float"},
    {"question": "Which of the following is a built-in function in Python? print, input, len", "answer": "len"},
    {"question": "What is the output of the following code? print('Hello, World!')", "answer": "Hello, World!"},
    {"question": "What is the data type of the following expression? 'Hello, World!'", "answer": "str"},
    {"question": "Which of the following is a valid variable name in Python? my_variable, 1_variable, my-variable", "answer": "my_variable"},
    {"question": "What is the output of the following code? print(2 ** 3)", "answer": "8"},
    {"question": "What is the data type of the following expression? True", "answer": "bool"},
    {"question": "Which of the following is a built-in data type in Python? int, float, str, bool, list, tuple, dict, set", "answer": "all of the above"},
    {"question": "What is the output of the following code? print(2 + '3')", "answer": "TypeError: unsupported operand type(s) for +: 'int' and 'tr'"},
]

# Shuffle the questions
random.shuffle(questions)

# Initialize the score
score = 0

# Loop through the questions
for question in questions:
    # Display the question
    print(question["question"])

    # Get the user's answer
    answer = input("Your answer: ")

    # Check if the answer is correct
    if answer.lower() == question["answer"].lower():
        print("Correct!")
        score += 1
    else:
        print("Incorrect. The correct answer is:", question["answer"])

# Display the final score
print("Your score is:", score, "/", len(questions))
    
